package com.wlwx.simulator.message.outbound;

import com.wlwx.simulator.codec.CMPPCommand;
import com.wlwx.simulator.message.basic.BaseOutBoundMessage;

import java.nio.ByteBuffer;

public class SubmitOutBoundResponse extends BaseOutBoundMessage {

    private long msgId;
    private byte result;

    public SubmitOutBoundResponse(int sequenceId) {
        super(CMPPCommand.CMPP_SUBMIT_RESP_COMMAND, sequenceId);
    }

    @Override
    public byte[] getBody() {
        ByteBuffer byteBuffer = ByteBuffer.allocate(9);
        byteBuffer
                .putLong(msgId)
                .put(result);
        return byteBuffer.array();
    }

    public long getMsgId() {
        return msgId;
    }

    public byte getResult() {
        return result;
    }

    public void setResult(byte result) {
        this.result = result;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer("CMPP20 SUBMIT RESP : [");
        sb.append("msgId")             .append(":").append(msgId             ).append(",");
        sb.append("result")            .append(":").append(result           );
        sb.append("]");
        return sb.toString();
    }

    public void setMsgId(long msgId) {
        this.msgId = msgId;
    }
}
